home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #05 (Dec85-Jan86) / pascal / Christmas Graphics 1-13 / VBLExample.pas < prev    next >
Pascal/Delphi Source File  |  1985-10-11  |  2KB  |  93 lines

  1. program VBLExample;{ file VBLExample.pas }
  2.  
  3. {  $I=Include these interface files }
  4. (*$I MemTypes.ipas  *)
  5. (*$I QuickDraw.ipas *)
  6. (*$I OSIntf.ipas    *)
  7. (*$I ToolIntf.ipas  *)
  8.  
  9. { We will convert this code with Rmaker in
  10.   such a way as to cause execution to begin
  11.   with the FIRST PROCEDURE, and not in the
  12.   main procedure.                }
  13.  
  14. TYPE
  15.  
  16.   GlobalDataP=^GlobalData;
  17.   GlobalData=record
  18.      vblPart:VBLTask;
  19.      count:longint;
  20.        end;{ 18 bytes long }
  21.     
  22. { var
  23.      no global variables allowed }
  24.      
  25. { the following four procs don't generate code now }
  26. Procedure SetA0(a0:longint);inline $205F;{ MOVE.l (SP)+,A0 }
  27. Procedure Vinstall_Trap;inline $A033;{ _Vinstall trap }
  28. Function GetGlobalData : GlobalDataP;FORWARD;
  29. Procedure VBLScreenTask;FORWARD;
  30.  
  31. { execution begins here }
  32. { We install VBLScreenTask in the VBL queue and 
  33.    set up the body of the dummy procedure as our
  34.    data record. }
  35.  
  36. Procedure InstallVBLTask;{ one time setup routine }
  37. var
  38.      cp : GlobalDataP;
  39. begin
  40.   cp := GetGlobalData;
  41.   cp^.count:=0;
  42.   with cp^.VBLPart do
  43.     begin
  44.         qType:=ord(vType);
  45.     vblAddr:=@VBLScreenTask;
  46.     vblCount:=1;
  47.     vblPhase:=0;
  48.     { This funky double step is my way of calling Vinstall 
  49.        without having to link with another file.  Register A0
  50.        is set and then the trap is called. }
  51.     SetA0(ord(@cp^.VBLPart));
  52.     Vinstall_Trap;
  53.     end;
  54. end;
  55.  
  56. Procedure Dummy;{ reserve some bytes in the code space }
  57. begin
  58.   Dummy; Dummy; Dummy; Dummy;{ 8 bytes }
  59.   Dummy; Dummy; Dummy; Dummy;{ 8 bytes }
  60.   Dummy;
  61. end;
  62.  
  63. Function GetGlobalData {: GlobalDataP};
  64.  begin
  65.   GetGlobalData := pointer(ord(@Dummy));
  66.  end;
  67.  
  68. { Reset the VBLCount so we remain in queue and
  69.   utilise $824 (SCRNBASE global) to find address
  70.   of the screen and write the count there.        }
  71.  
  72. Procedure VBLScreenTask;
  73.    var
  74.        cp : GlobalDataP;
  75.        ScreenP:^longint;
  76. begin
  77.   ScreenP:=pointer($824);
  78.   ScreenP:=pointer(ScreenP^);
  79.   cp:=GetGlobalData;
  80.   with cp^ do 
  81.       begin
  82.          count:=count+1;
  83.      with VBLpart do
  84.          begin
  85.            VBLCount:=1;
  86.            ScreenP^:=count;
  87.          end;
  88.        end;
  89.  end;{ vbltask }
  90.   
  91. begin{ main }
  92.     { ¡¡¡ main procedure not used !!! }
  93. end.